define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vender/index' + location.search,
                    add_url: 'vender/add',
                    edit_url: 'vender/edit',
                    del_url: 'vender/del',
                    multi_url: 'vender/multi',
                    table: 'vender',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'vender_id',
                sortName: 'vender_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'vender_id', title: __('Vender_id')},
                        {field: 'parent_vender_id', title: __('Parent_vender_id')},
                        {field: 'vender_name', title: __('Vender_name')},
                        {field: 'user_name', title: __('User_name')},
                        {field: 'user_pwd', title: __('User_pwd')},
                        {field: 'ctime', title: __('Ctime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'login_ip', title: __('Login_ip')},
                        {field: 'login_time', title: __('Login_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'prov', title: __('Prov')},
                        {field: 'city', title: __('City')},
                        {field: 'area', title: __('Area')},
                        {field: 'district', title: __('District')},
                        {field: 'vender_type', title: __('Vender_type')},
                        {field: 'status', title: __('Status')},
                        {field: 'role_id', title: __('Role_id')},
                        {field: 'utime', title: __('Utime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'memo', title: __('Memo')},
                        {field: 'prov_name', title: __('Prov_name')},
                        {field: 'city_name', title: __('City_name')},
                        {field: 'area_name', title: __('Area_name')},
                        {field: 'company', title: __('Company')},
                        {field: 'lang', title: __('Lang')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});